<?php
// +----------------------------------------------------------------------
// | Author: wyd 2025/11/2
// | DESC: 
// +----------------------------------------------------------------------

declare (strict_types=1);

/**1、创建通道*/

use Swoole\Coroutine\Channel;
use function Swoole\Coroutine\run;

run(function () {
    //参数为最大通道数量
    $channel = new Channel(1);
    go(function () use ($channel){
       $res = "内部需要返回的值\n";
       $channel->push($res);  //把值放入通道
    });

    //从通道中取出值；
    $res = $channel->pop();
    echo $res;
});